<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript">

	/**
	 * 被选中的页面
	 */
	var selectids = "<%=request.getAttribute("selectids")%>";
	/**
	 * 分配参会人员
	 */
	function assignkeyword(){
		var url = "sendMessEnterController.do?assignEnter";
		var selectV = getassignenterListSelections("id");
		url += '&ids='+selectV;
		url += "&xxid="+"${xxid}";
		$.ajax({
			async : false,
			cache : false,
			type : 'post',
			url : url,// 请求的action路径
			error : function() {// 请求失败处理函数
				
			},
			success : function(data) {
				var d = $.parseJSON(data);
				if (d.success) {
					$.messager.show({
						title : '提示消息',
						msg : '分配成功',
						timeout : 2000,
						showType : 'slide'
					});
					selectids = d.obj;
					setSelectedUser();
				}
			}
		});
	}


	/**
	 * 解除判断题
	 */
	function cancelkeyword(){
		var url = "sendMessEnterController.do?delEnter";
		var selectV = getassignenterListSelections("id");
		url += '&ids='+selectV;
		url += "&xxid="+"${xxid}";
		$.ajax({
			async : false,
			cache : false,
			type : 'post',
			url : url,// 请求的action路径
			error : function() {// 请求失败处理函数
				
			},
			success : function(data) {
				var d = $.parseJSON(data);
				if (d.success) {
					$.messager.show({
						title : '提示消息',
						msg : '解除成功',
						timeout : 2000,
						showType : 'slide'
					});
					selectids = d.obj;
					setSelectedUser();
				}
			}
		});
	}


	/**
	 * 设置被选择
	 */
	function setSelectedUser(){			
		var ids = [];
		var rows = $('#assignenterList').datagrid("getRows");
		for(var i=0;i<rows.length;i++){
			if(selectids.indexOf(","+rows[i]["id"]+",")>=0)
				$('#assignenterList').datagrid("selectRow",i);
			else 
				$('#assignenterList').datagrid("unselectRow",i);
		}
	}
</script>
<div class="easyui-layout" fit="true">
	<div region="center" style="padding:1px;">
		<t:datagrid name="assignenterList" title="单位" checkbox="true"
			actionUrl="enterController.do?datagrid" idField="id" fit="true"
			onLoadSuccess="setSelectedUser">
			<t:dgCol title="编号" field="id" hidden="false"></t:dgCol>
			<t:dgCol title="单位帐号" field="account" width="120"></t:dgCol>
			<t:dgCol title="单位名称" field="name" width="200"></t:dgCol>
			<t:dgToolBar title="分配单位" icon="icon-add" funname="assignkeyword"></t:dgToolBar>
			<t:dgToolBar title="解除单位" icon="icon-remove" funname="cancelkeyword"></t:dgToolBar>	
		</t:datagrid>
	</div>
</div>

<script>

	
</script>